home *** CD-ROM | disk | FTP | other *** search
- Path: rain.fr!world-net!usenet
- From: Frederic LACHASSE <lachass@worldnet.fr>
- Newsgroups: comp.lang.c++
- Subject: Re: Newbie Question on using function ptr or Casting?
- Date: Sun, 17 Mar 1996 07:35:14 +0000
- Organization: World-Net information exchange, Internet provider.
- Message-ID: <VA.0000006b.000286c0@fred>
- References: <19960314170244.sstryker@sover.net>
- Reply-To: lachass@worldnet.fr
- NNTP-Posting-Host: client122.sct.fr
- X-Newsreader: Virtual Access by Ashmount Research Ltd, http://www.ashmount.com
-
- Short answer: you often use in programs containers like lists,
- stacks, arrays and tables to store objects. Way of handling such
- containers are always the same, so it looks like a good idea to create
- classes to implement container behavior that would be (mostly)
- independant from the objects stored in them.
-
- One way of building such a generic container class is to store pointers
- to a simple base class. In this program, they just use the most basic of
- pointers, that is void*.
-
- This system has a drawback: you must cast back the pointer from these
- containers to the original class, and it's not type safe.
-
- The new "template" feature of C++ allow the definition of generic
- type-safe containers will render the old style container classes
- obsolete, the more so as the STL (Standard Template Library) will be
- included in the forthcoming C++ standard and implement array, deque,
- linked list, map, tree and other common containers.
-
- Frederic LACHASSE (ECP 86)
- CompuServe: 100530,2005
- Internet: lachass@worldnet.fr
-
-